﻿namespace Sidvall.FileSystemManager.Net.Services.V1
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class PathName : global::Sidvall.Data.ServiceDataRowBase, global::Sidvall.FileSystemManager.Data.IPathName
    {
        #region Public Members

        #region Folder

        private string _Folder;
        partial void OnBeforeFolderPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterFolderPropertyChanged();
        public string Folder
        { 
            get
            {
                return _Folder;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _Folder = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Folder);
                    OnBeforeFolderPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("Folder", eventData.Value, true, true);
                        OnAfterFolderPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region FullName

        private string _FullName;
        partial void OnBeforeFullNamePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterFullNamePropertyChanged();
        public string FullName
        { 
            get
            {
                return _FullName;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _FullName = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _FullName);
                    OnBeforeFullNamePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("FullName", eventData.Value, true, true);
                        OnAfterFullNamePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region IsFolder

        private bool _IsFolder;
        partial void OnBeforeIsFolderPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsFolderPropertyChanged();
        public bool IsFolder
        { 
            get
            {
                return _IsFolder;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _IsFolder = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsFolder);
                    OnBeforeIsFolderPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("IsFolder", eventData.Value, true, true);
                        OnAfterIsFolderPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region Name

        private string _Name;
        partial void OnBeforeNamePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterNamePropertyChanged();
        public string Name
        { 
            get
            {
                return _Name;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _Name = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Name);
                    OnBeforeNamePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("Name", eventData.Value, true, true);
                        OnAfterNamePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region PathNameId

        private System.Nullable<int> _PathNameId;
        partial void OnBeforePathNameIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData);
        partial void OnAfterPathNameIdPropertyChanged();
        public System.Nullable<int> PathNameId
        { 
            get
            {
                return _PathNameId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _PathNameId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<int>>(value, _PathNameId);
                    OnBeforePathNameIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("PathNameId", eventData.Value, true, true);
                        OnAfterPathNameIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region Size

        private System.Nullable<long> _Size;
        partial void OnBeforeSizePropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterSizePropertyChanged();
        public System.Nullable<long> Size
        { 
            get
            {
                return _Size;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _Size = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _Size);
                    OnBeforeSizePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("Size", eventData.Value, true, true);
                        OnAfterSizePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.DataRowStateIsDirty(this);
            }
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool updateState)
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.LoadInstanceField(this, fieldName, value, cascade, false, updateState);
        }

        #endregion
        #region Copy

        public PathName Copy()
        {
            return global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.Copy(this);
        }
        public PathName Copy(Sidvall.Data.CopySettings settings)
        {
            return global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.Copy(this, settings);
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.FileSystemManager.Data.IPathName item)
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.Import(this, item);
        }
        public void Import(global::Sidvall.FileSystemManager.Data.IPathName item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.Import(this, item, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.ValidateAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.ValidateAsync(this, settings).ConfigureAwait(false);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.Initialize(this, settings);
        }

        #endregion

        #region IPathName Members

        string global::Sidvall.FileSystemManager.Data.IPathName.Folder
        {
            get
            {
                return this._Folder;
            }
            set
            {
                this._Folder = value;
            }
        }
        string global::Sidvall.FileSystemManager.Data.IPathName.FullName
        {
            get
            {
                return this._FullName;
            }
            set
            {
                this._FullName = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.IPathName.IsFolder
        {
            get
            {
                return this._IsFolder;
            }
            set
            {
                this._IsFolder = value;
            }
        }
        string global::Sidvall.FileSystemManager.Data.IPathName.Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                this._Name = value;
            }
        }
        System.Nullable<int> global::Sidvall.FileSystemManager.Data.IPathName.PathNameId
        {
            get
            {
                return this._PathNameId;
            }
            set
            {
                this._PathNameId = value;
            }
        }
        System.Nullable<long> global::Sidvall.FileSystemManager.Data.IPathName.Size
        {
            get
            {
                return this._Size;
            }
            set
            {
                this._Size = value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public PathName()
        {
        }
        public PathName(bool initializeDefaultValues)
            : this(initializeDefaultValues, null, Sidvall.Business.BusinessEvents.None)
        {
        }
        public PathName(bool initializeDefaultValues, Sidvall.Data.DataRowState? dataRowState, Sidvall.Business.BusinessEvents enabledBusinessEvents)
            : base(dataRowState, enabledBusinessEvents)
        {
            if (initializeDefaultValues)
                global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.PathNameManager.Initialize(this);
        }

        #endregion
    }
}